package ie.lawlor.amvc.component.piechart;


import ie.lawlor.amvc.patterns.standard.StandardModel;

import java.util.Iterator;
import java.util.Map;


/**
 * @author blawlor
 *
 */
public abstract class PieChartModel extends StandardModel {
	
	protected Map slices;

  public PieChartModel(String name){
		super(name);
	}
  
  public abstract String getPieTitle();
  
  public String[] getSliceNames() {
    String[] result = new String[slices.keySet().size()];
    int index = 0;
    for (Iterator itr = slices.keySet().iterator(); itr.hasNext();){
      String key = (String)itr.next();
      result[index++] = key;
    }
    return result;
  }

  public int[] getSliceValues() {
    int[] result = new int[slices.keySet().size()];
    int index = 0;
    for (Iterator itr = slices.keySet().iterator(); itr.hasNext();){
      String key = (String)itr.next();
      result[index++] = ((Integer)slices.get(key)).intValue();
    }
    return result;
  }
  
}
